﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld"%>

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />
<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body>

	<%@ include file="/WEB-INF/include/header.jsp"%>

	<%@ include file="/WEB-INF/include/menu.jsp"%>

	<div class="container main-content">

		<div class="panel panel-default x-panel x-panel-layout">

			<div class="panel-heading">
				<ol class="breadcrumb">
					<li><a href="${ctx.host}/ecommerce">渠道管理</a></li>
					<li class="active">用户渠道数据</li>
				</ol>
			</div>

			<div class="panel-body">

				<div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
					<%@ include file="/WEB-INF/include/submenu.jsp"%>
				</div>

				<div class="col-xs-10 x-panel-layout-right">

					<div class="x-breadcrumb-wrapper">
						<div class="x-breadcrumb clearfix">
							<h2>
								<i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>渠道管理&nbsp;-&nbsp;用户渠道数据</span>
							</h2>
							<div class="pull-right">
								<c:choose>
									<c:when test="${not empty currentPrincipal.site}">
										<span class="current-branchCode">${currentPrincipal.site.name}</span>
									</c:when>
									<c:otherwise>
										<select name="site">
											<option value="">所有门店</option>
											<c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
												<option value="${site.id}" ${site.id == param.site ? 'selected' : ''}>${site.name}</option>
											</c:forEach>
										</select>
									</c:otherwise>
								</c:choose>
							</div>
						</div>

						<div class="x-breadcrumb-wrapper clearfix" style="position: relative; margin-top: 15px;">
							<div class="btn-group pull-left">
							  <a href="${ctx.host}/user-source/import" data-target="#" data-toggle="modal" class="btn btn-success x-btn btn-shadow btn-shadow-success"> <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;导入渠道记录
                </a>
							</div>
							<div class="btn-group pull-right">
							  <a id="addSource" href="${ctx.host}/user-source/create" data-target="#addModal" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default"> <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;新资源
                </a>
								<a id="addRecord" href="${ctx.host}/user-source/create-record" data-target="#addRecordModal" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default"> <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;客户回访
                </a>
								<a href="${ctx.host}/user-source/search" data-target="#" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default"> <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
								</a>
							</div>
						</div>

						<div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
              <ul class="nav nav-pills x-breadcrumb-nav">
                <c:forEach var="userSourceStatus" items="${enums['userSourceStatus']}">
                  <li class="pull-left ${status == userSourceStatus.name() ? 'active' : ''}"><a href="${ctx.host}/user-source?status=${userSourceStatus.name()}">${userSourceStatus.description}</a></li>
                </c:forEach>
              </ul>
            </div>
					</div>
					<table class="table table-striped table-hover x-table" style="margin-bottom: 20px;">
						<thead>
							<tr>
								<th>所属<br />门店</th>
								<th>用户<br />姓名</th>
								<th>用户<br />性别</th>
								<th>用户<br />手机</th>
								<th>所属<br />渠道</th>
								<th>用户<br />微信号</th>
								<th>首次<br />接待日期</th>
								<th>首次<br />接待人员</th>
								<th>学员<br />需求</th>
								<th>预约<br />时间</th>
								<th>预约<br />教练</th>
								<th>是否<br />到店</th>
								<th>是否<br />成单</th>
								<th class="text-center">操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="userSource" items="${userSources}">
								<tr>
									<td>${userSource.site.name}</td>
									<td>${userSource.name}</td>
									<td>${userSource.gender}</td>
									<td>${userSource.mobile}</td>
									<c:choose>
									 <c:when test="${empty userSource.userSourceType}">
									   <td>${userSource.userSourceTypeName}</td>
									 </c:when>
									 <c:otherwise>
									   <td>${userSource.userSourceType.name}&nbsp;&nbsp;&nbsp;&nbsp;${userSource.typeOther}</td>
									 </c:otherwise>
									</c:choose>
									<td>${userSource.wechatnumber}</td>
									<td>${userSource.occurDate}  ${userSource.occurHour}</td>
									<c:choose>
                   <c:when test="${empty userSource.receiver}">
                     <td>${userSource.receiverName}</td>
                   </c:when>
                   <c:otherwise>
                     <td>${userSource.receiver.name}</td>
                   </c:otherwise>
                  </c:choose>
									<td>${userSource.requirement}</td>
									<td><fmt:formatDate value="${userSource.visitedDate}" pattern="yyyy-MM-dd" /></td>
									<td>${userSource.coach.name}</td>
									<td>${userSource.visited ? '是' : '否'} <br /> ${userSource.visitedReason}</td>
									<td>${userSource.ordered ? '是' : '否'}</td>
									<td>
									  <a href="${ctx.host}/user-source/${userSource.id}">详情</a>&nbsp;&nbsp;
									  <a href="${ctx.host}/user-source/${userSource.id}/edit" data-target="#" data-toggle="modal">编辑</a>&nbsp;&nbsp;
									  <a href="${ctx.host}/user-source/${userSource.id}/return" data-target="#" data-toggle="modal">标记拒绝</a>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>

					<jsp:include page="/WEB-INF/include/page.jsp">
						<jsp:param name="url" value="user-source" />
						<jsp:param name="queryString" value="${queryString}" />
					</jsp:include>

				</div>
			</div>
		</div>
	</div>

	<%@ include file="/WEB-INF/include/script.jsp"%>
	<d:resource root="${ctx.resource}/build" type="script" src="js/page/usersource/usersource-list.js">
		<script type="text/javascript">
      require(['page/usersource/usersource-list'], function(page) {
        page.init({
        	"status": "${status}"
        })
      })
    </script>
	</d:resource>

</body>

</html>
